dir_src = ./src
dir_inc = ./include
dir_bin = ./bin
dir_obj = ./obj
ter_mkdir = mkdir

src = $(wildcard $(dir_src)/*.c)
obj = $(patsubst %.c, $(dir_obj)/%.o, $(notdir $(src)))

target = out
bin_target = $(dir_bin)/$(target)

.PHONY : clean run

$(bin_target) : $(obj)
	@$(ter_mkdir) -p $(dir_bin)
	@cc -w $(obj) -o $@ -I$(dir_inc)

$(dir_obj)/%.o : $(dir_src)/%.c
	@$(ter_mkdir) -p $(dir_obj)
	@cc -w -c $< -o $@ -I$(dir_inc)

clean :
	@-rm -rf $(dir_bin) $(dir_obj)

run :
	@./$(bin_target)
